const express = require('express');
const router = express.Router();
const userController = require('../controllers/userController');
const { authenticate, authorize } = require('../middleware/auth');
const upload = require('../middleware/upload');

// 获取所有用户(管理员权限)
router.get('/', authenticate, authorize('admin'), userController.getAllUsers);

router.get('/:id', userController.getUser);
router.put('/', authenticate, userController.updateUser);
router.post('/avatar', authenticate, upload.single('avatar'), userController.updateAvatar);

module.exports = router;